# !/usr/bin/env python
# -*- coding: utf-8 -*-
# @File  : openai_test.py
# @Author: dongguangwen
# @Date  : 2024-06-29 18:18
# import openai
#
# openai.api_key = 'sk-YnE2e3Ho6ygKaUlRYRnUHGTewdRzKLJQ5oSyp2fhLl35DEkZ'
# openai.base_url = 'https://api.chatanywhere.tech/v1'
# response = openai.Completion.create(
#     model='text-davinci-003',
#     temperature=0.7,
#     max_tokens=1024,
#     prompt="给我一个关于努力学习的，四字成语"
# )
#
# print(response)


import os
import openai
from openai import OpenAI

# openai.base_url = 'https://api.chatanywhere.tech/v1'

client = OpenAI(
    # This is the default and can be omitted
    api_key=os.environ.get("OPENAI_API_KEY", 'sk-YnE2e3Ho6ygKaUlRYRnUHGTewdRzKLJQ5oSyp2fhLl35DEkZ'),
)

chat_completion = client.chat.completions.create(
    messages=[
        {
            "role": "user",
            "content": "Say this is a test",
        }
    ],
    model="gpt-3.5-turbo",
)
print(chat_completion)
